<template>
	<view class="seckill-product-wrap">
        <view style="width: 100%;margin-top: -100rpx">
            <image src="http://img.pighack.com/20220614095028e45864915.png" style="width: 100%" mode="widthFix"></image>
        </view>

        <view style="margin-top: -410rpx">
            <scroll-view scroll-X="true" show-scrollbar="false" class="scroll-X  ">
                <view class="tab-list "  style="padding:0 20rpx;display: flex ">
                    <view  :class="type_active == index ? 'tab-item2 active2 linedot' : 'tab-item2 linedot'"  v-for="(item, index) in activeList" :key="index"
                          @click="tabTypeFunc(index)">
                        {{ item.title }}
                    </view>
                </view>
            </scroll-view>
            <view class="hlbblock" style="margin-top: 80rpx;">
                <view style="background-color: rgba(254,58,58,0.05)">
                    <view style="padding: 30rpx">
                        <view style="display: flex;align-items: center;justify-content: center;">
                            <view>
                                <image  src="/static/images/groupearn/clock.png" style="width: 40rpx;margin: 10rpx" mode="widthFix"></image>
                            </view>
                            <view>
                                距结束还剩：
                            </view>
                            <view>
                                <u-count-down  separator="colon" color="#FFFFFF" bg-color="#3CA1FF"  separator-color="#2c2b2b" font-size="25" separator-size="25" height="45"   :timestamp="diftime" ></u-count-down>
                            </view>
                        </view>
                    </view>
                </view>
                <view class="" style="padding: 20rpx;" v-if="!loading">
                    <scroll-view scroll-y="true" class="scroll-Y"  lower-threshold="50">
                        <view style="display: flex;width: 100%;;margin-top: 20rpx" v-for="(item, index) in listData" :key="index">
                            <view style="position: relative">
                                <image :src="item.product_image" style="width: 240rpx;height: 240rpx;border-radius: 15rpx" mode="aspectFit"></image>
                            </view>
                            <view style="margin-left: 20rpx;width: 70%">
                                <view style="height: 160rpx">
                                    <view>
                                        {{ item.product_name }}
                                    </view>
                                </view>
                                <view style="width: 100%;display: flex;align-items: center">
                                    <view style="display: flex;align-items: center;width: 50%;overflow: hidden">
                                        <view style="color: #F63E36;font-size: 32rpx">
                                            ￥{{ item.product_price }}
                                        </view>
                                        <!-- <view class="text-d-line" style="color: #999999;font-size: 24rpx">
                                            ￥{{ item.product_price }}
                                        </view> -->
                                    </view>
                                    <view @click="gotoDetail(item.product_id)" class="hlbbutton" style="background-color: #3CA1FF;height: 56rpx;line-height: 56rpx;width: 140rpx">
                                        去购买
                                    </view>
                                </view>
                            </view>
                        </view>
                    </scroll-view>
                </view>
            </view>
        </view>
	</view>
</template>

<script>
	import Countdown from '@/components/countdown/countdown.vue';
	export default {
		components: {
			Countdown
		},
		data() {
			return {
				/*手机高度*/
				phoneHeight: 0,
				/*可滚动视图区域高度*/
				scrollviewHigh: 0,
				/*活动列表*/
				activeList: [],
				/*当前活动角标*/
				type_active: 0,
				/*类别选中*/
				currActive: {},
				/*产品列表*/
				listData: [],
				/*活动详情*/
				detailData: {},
				/*是否正在加载*/
				loading: true,
				/*倒计时配置*/
				countdownConfig: {
					/*开始时间*/
					startstamp: 0,
					/*结束时间*/
					endstamp: 0
				},
                diftime :0,
			};
		},
		computed: {},
		onShow() {
			this.getActive();
		},
		mounted() {
			this.init();

		},
		onPullDownRefresh() {},
		methods: {
			/*初始化*/
			init() {
				let _this = this;
				/*uni.getSystemInfo({
					success(res) {
						_this.phoneHeight = res.windowHeight;
						// 计算组件的高度
						let view = uni.createSelectorQuery().select('.top-box');
						view.boundingClientRect(data => {
							let h = _this.phoneHeight - data.height + 43;
							_this.scrollviewHigh = h;
						}).exec();
					}
				});*/
			},

			/*类别切换*/
			tabTypeFunc(e) {
				this.type_active = e;
				this.currActive = this.activeList[e];
				this.getData();
			},
			goback() {
				uni.navigateBack({

				})
			},
			/*获取活动类别*/
			getActive() {
				let self = this;
				let param = {};
				self.loading = true;
				self._get(
					'plus.seckill.product/active', {
						param
					},
					function(res) {
						self.activeList = res.data.list;
						if (self.activeList && self.activeList.length > 0) {
							self.currActive = self.activeList[0];
							self.getData();
						}
					}
				);
			},

			/*获取数据*/
			getData() {
				let self = this;
				self.loading = true;
				self._get(
					'plus.bonus.bonus/bonus_index', {
					},
					function(res) {
						self.listData = res.data.product;
						console.log(666666)
						console.log(self.listData)
						self.countdownConfig.endstamp = res.data.data.end_time;
						self.countdownConfig.startstamp = res.data.data.start_time;
                        self.diftime  =self.countdownConfig.endstamp-Date.parse(new Date())/1000;
                        uni.hideLoading();
						self.loading = false;
					}
				);
			},

			/*跳转产品详情*/
			gotoDetail(e) {
				// this.$refs.countdown.clear();
				this.gotoPage('pages/product/detail/detail?product_id=' + e);
			},

			/*跳转搜索页面*/
			gotoSearch() {
				this.getData();
			},

			/*倒计时返回值*/
			returnValFunc(e) {

			}
		}
	};
</script>

<style lang="scss">
	page {
		background-color: #F2F2F2;
	}
    .tab-item2 {
        height: 80rpx;
        font-size: 28rpx;
        color: rgba(255, 255, 255, 0.50);
        width: 30%;
        text-align: center;

    }

    .tab-item2.active2 {
        margin-bottom: -2px;
        color: #FFFFFF;
        font-size: 30rpx !important;
        font-weight: bold;
        position: relative;
        width: 30%;
    }

    .tab-item2.active2::after {
        content: '';
        width: 72rpx;
        height: 8rpx;
        background: #FFFFFF;
        border-radius: 4rpx;
        position: absolute;
        bottom: 16rpx;
        left:30%;

    }

	.top-box {
		position: relative;
	}

	.seckill-product-wrap .tab-item {
		flex: 0;
		padding: 0 30rpx;
		font-size: 33rpx;
		height: 86rpx;
		line-height: 86rpx;
		white-space: nowrap;
		color: #333333;
	}

	.seckill-product-wrap .tab-item.active {
		color: #F6220C;
		font-size: 33rpx;
		opacity: 1;
		position: relative;
	}

	.seckill-product-wrap .tab-item.active::after {
		content: "";
		width: 120rpx;
		height: 4rpx;
		background: #F6220C;
		border-radius: 2rpx;
		position: absolute;
		border: 30rpx;

	}

	.seckill-product-wrap .every-day-time text {
		padding: 8rpx 16rpx;
		font-size: 26rpx;
		color: #333;
		opacity: 0.5;
	}

	.seckill-product-wrap .ad-activity {
		position: relative;
		overflow: hidden;
	}

	.seckill-product-wrap .ad-activity image {
		width: 750rpx;
		height: 367rpx;
	}

	.seckill-list-wrap {}

	.seckill-list-wrap .list .item {
		padding: 30rpx;
		display: flex;
		border-radius: 16rpx;
		margin-bottom: 20rpx;
		background: #ffffff;
	}

	.seckill-list-wrap .product-cover,
	.seckill-list-wrap .product-cover image {
		width: 200rpx;
		height: 200rpx;
	}

	.active-top-tab .ad-datetime::v-deep .box {
		height: 40rpx;
		padding: 4rpx;
		line-height: 40rpx;
		text-align: center;
		border-radius: 8rpx;
		font-size: 28rpx;
		background: #F6220C;
		color: #FFFFFF;
	}

	.active-top-tab .ad-datetime::v-deep text {
		color: #333;
		font-size: 28rpx;
	}

	.seckill-list-wrap .product-title {
		display: -webkit-box;
		overflow: hidden;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
		font-size: 32rpx;
	}

	.seckill-list-wrap .already-sale {
		padding: 4rpx 0;
		color: #8228EB;
		font-size: 22rpx;
	}

	  .slider {
		margin-top: 11rpx;
		height: 8rpx;
		background: #F2F2F2;
		border-radius: 5rpx;
	}

	  .slider-inner {
		height: 8rpx;
		background: linear-gradient(to right, #FE3A3A , #FE6236);
		border-radius: 4rpx;
	}

	.seckill-list-wrap .right-btn button {
		background: linear-gradient(90deg, #FF6B6B 4%, #F6220C 100%);
		color: #ffffff;
		height: 60rpx;
		border-radius: 30rpx;
		line-height: 60rpx;
	}

	.reg180 {
		padding-right: 20rpx;
		text-align: right;
		transform: rotateY(180deg);
		position: absolute;
		bottom: 0;
	}

	.icon-jiantou {
		color: #FFFFFF;
		font-size: 30rpx;
	}

	.head_top {
		position: absolute;
		top: 0;
		z-index: 20;
		padding-top: var(--status-bar-height);
		height: 30px;
		line-height: 30px;
		color: #FFFFFF;
		font-size: 28rpx;
	}

	.tab-item.active::after {
		content: '';
		width: 60%;
		height: 4rpx;
		background: #F2F2F2;
		border-radius: 2rpx;
		position: absolute;
		bottom: 5rpx;
	}
</style>
